package com.shop2cn.iapi.agentproducts.testcase;

import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ImportAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.OffShelfOrDeleteProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ProductListDto;
import com.shop2cn.iapi.agentproducts.service.OffShelfOrDeleteProductCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
/**
*单个下架或者移出商品Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_OffShelfOrDeleteProduct{
	private static OffShelfOrDeleteProductBean offshelfordeleteproductBean;
	private static OffShelfOrDeleteProductCall offshelfordeleteproductCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("单个下架或者移出商品Test");
	}

	@Before
	public void caseUp() {
		offshelfordeleteproductBean=new OffShelfOrDeleteProductBean();
		offshelfordeleteproductCall=new OffShelfOrDeleteProductCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(offshelfordeleteproductCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_OffShelfOrDeleteProduct_001() {
		Logger.start(true,"正确数据，成功");
		try {
			
			Integer MchId = GodmchManageCallService.CreateGodMch();
            Integer agenttype=GodmchManageCallService.getAgentType(MchId, 1);
            Integer AgentId = GodmchManageCallService.getAgentMchId(MchId, agenttype);
			//添加导入商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean initImportAgentProduct = AddAgentProductCallService.initImportAgentProduct(AgentId, "", productId, MchId, false);
			String AgentProductId = AddAgentProductCallService.ImportAgentProduct(initImportAgentProduct);
			
			offshelfordeleteproductBean.setUserId(MchId);
			offshelfordeleteproductBean.setProductId(productId);
			offshelfordeleteproductCall.setData(offshelfordeleteproductBean);
			offshelfordeleteproductCall.callService();			
			Logger.verifyEquals("ok", offshelfordeleteproductCall.getReturnData(), "验证code");
			
			
			Thread.sleep(3000);
			List<ProductListDto> getProductLists = AddAgentProductCallService.GetProductLists(MchId);
			Logger.verifyEquals(0, getProductLists.size(), "验证上架商品");
			List<ProductListDto> getProductLists1 = AddAgentProductCallService.GetProductLists(AgentId);
			Logger.verifyEquals(0, getProductLists1.size(), "验证上架商品");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}